﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FTP操作;

namespace CallCenter外部上传子程序
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        string strDate = DateTime.Now.ToString("yyyyMMdd");

        private void btnFile_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtFilePath.Text = openFileDialog1.FileName;
            }
        }

        string ftpAddr = ConfigurationManager.AppSettings["ftpAddr"];
        string ftpUserName = ConfigurationManager.AppSettings["ftpUserName"];
        string ftpPassword = ConfigurationManager.AppSettings["ftpPassword"];
        string deptNo = ConfigurationManager.AppSettings["deptNo"];

        private void btnUpload_Click(object sender, EventArgs e)
        {
            FtpClient fc = new FtpClient(ftpAddr, ftpUserName, ftpPassword);
            fc.Upload(new FileInfo(txtFilePath.Text), deptNo + strDate + ".xls");
            string MD5 = MD5Helper.MD5Value(txtFilePath.Text);
            MessageBox.Show(MD5);
            string newMD5 = MD5Helper.GetMD5(MD5 + "Test");
            File.WriteAllText(@"C:\1.txt",newMD5);
            fc.Upload(new FileInfo(@"C:\1.txt"), deptNo + strDate + ".txt");
            MessageBox.Show("上传成功");
        }
    }
}
